{% extends 'myadmin/index.html' %}

{% block title %}
<title>后台-会员订单</title>
{% endblock %}
{% block index %}
<a href="{% url 'myadmin_index' %}">
    <i class="am-icon-home sidebar-nav-link-logo"></i> 首页
</a>
{% endblock %}
{% block order %}
<li class="sidebar-nav-link">
    <a href="javascript:;" class="sidebar-nav-sub-title active">
        <i class="am-icon-shopping-bag sidebar-nav-link-logo"></i> 订单管理
        <span class="am-icon-chevron-down am-fr am-margin-right-sm sidebar-nav-sub-ico"></span>
    </a>
    <ul class="sidebar-nav sidebar-nav-sub">
        <li class="sidebar-nav-link">
            <a href="{% url 'myadmin_order_index' %}">
                <span class="am-icon-angle-right sidebar-nav-link-logo"></span> 订单列表
            </a>
        </li>
    </ul>
</li>
{% endblock %}




{% block main %}

<script type="text/javascript" src="/static/myadmin/js/jquery.min.js"></script>
<div class="row-content am-cf">
  <div class="row">
    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
      <div class="widget am-cf">
        <div class="widget-head am-cf">
          <div class="widget-title  am-cf">订单列表</div></div>
        <div class="widget-body  am-fr">
          <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
            <div class="am-form-group">
              <div class="am-btn-toolbar">
             
              </div>
            </div>
          </div>
          <form>
          <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
 <!--            <div class="am-form-group tpl-table-list-select">
              <select name="types" data-am-selected="" class="sel">
                <option value="all"{% if request.GET.types == 'all' %} selected {% endif %}>所有</option>
                <option value="title"{% if request.GET.types == 'title' %} selected {% endif %}>商品标题</option>
                <option value="price"{% if request.GET.types == 'price' %} selected {% endif %}>价格</option>
                <option value="status"{% if request.GET.types == 'status' %} selected {% endif %}>状态</option>
                </select>
            </div> -->
          </div>
       <!--    <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
            <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p inp">
              <input value="" type="text" class="am-form-field " name="textVal">
              <span class="am-input-group-btn">
                <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search"></button>
              </span>
            </div> -->
          </div>
          </form>
         
          <div class="am-u-sm-12">
            <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " id="">
              <thead>
                <tr>
                  <th>ID</th>
                  <th>订单编号</th>
                  <th>订单总价</th>
                  <th>支付方式</th>
                  <th>收货地址</th>
                  <th>订单状态</th>
                  <th>购买时间</th>
                  <th>购买用户</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
              {% for i in data %}
                <tr class="gradeX">
                  <td>{{i.id}}</td>
                  <td>{{i.dingId}}</td>
                  <td>{{i.priceSum}}</td>
                  <td>{{i.mode}}</td>
                  <td class="add" title="{{i.address}}">{{i.address}}</td>
                  <td class="ab">
                    {% if i.status == 0 %}
                        未付款
                    {% elif i.status == 1 %}
                        已付款
                    {% elif i.status == 2 %}
                        订单已被删除
                    {% elif i.status == 3 %}
                        未发货
                    {% elif i.status == 4 %}
                        已发货
                    {% endif %}
                  </td>
                  <td>{{i.addtime}}</td>
                  <td>{{i.userid.username}}</td>
                  <td>
                    <div class="tpl-table-black-operation">
                    {% if i.status == 1 or i.status == 3 %}
                     <a href="javascript:;" class="tpl-table-black-operation-del fahuo">
                                发货</a>
                    
                    {% endif %}
                    </div>
                    <div class="tpl-table-black-operation">
                    <a href="{% url 'myadmin_order_list' %}?id={{i.id}}" class="tpl-table-black-operation-del info">
                                查看订单详情</a>
                  </td>
                  </div>
                </tr>
                {%endfor %}
                <!-- more data --></tbody>
            </table>
          </div>
          <div class="am-u-lg-12 am-cf">
            <div class="am-fr">
              <ul class="am-pagination tpl-pagination">
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
  lens = $(".add").text().length
  if (lens>10){
    $(".add").text($(".add").text().slice(0,10)+"...")
  }

  // 发货
  $(".fahuo").click(function(){
    id = $(this).parents("tr").find("td:first").text()
    el = $(this)
    $.get('{% url 'myadmin_order_fahuo' %}',{"id":id},function(data){
          if(data=="ok"){
              alert("发货成功!")
              el.parents("tr").find(".ab").text("已发货")
              el.remove()
              
          }
    })
  })
  //查看详情
</script>
</div>
{% endblock %}